package com.luhongzhe.tool;

/**
 * @author 	luhongzhe
 * @email  	azhe0660@gmail.com
 * @date   	2011-10-10
 */

public class PhysicalTool
{
//	s = v0·t + a·t²/2
//	末速度的平方-初速度的平方=2*加速度*路程
	
//	已知：
	float initialV;
	float acceleration;
	int time;
	
	public static final float gravityA = 0.001f;
	
	public static final float getDistance(float initialV, float acceleration, int time)
	{
		return initialV * time + acceleration * time * time / 2;
	}
	
	public static final float getFallingDistance(float initialV, int time)
	{
		return getDistance(initialV, gravityA, time);
	}
	
	public static final float getTime(float distance, float initialV, float acceleration)
	{
		return (float)(Math.sqrt(2 * acceleration * distance + initialV * initialV) - initialV) / acceleration;
	}
}
